package com.zcsy.commons.constants;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import com.zcsy.manage.model.common.SelectInfo;
import com.zcsy.manage.model.system.User;


/**
 * 系统常量类
 * @author tanghan
 * @version 2015年2月10日
 * @see Constants
 * @since
 */
public class Constants{
    
    public static final int PROPERTY_FEEBILL_PAYTIME_TYPE = 3;//物业配置---"property_feebill_paytime"编辑页面的区分
    public static final int cell_service_phone_TYPE = 4;//小区配置---"cell_service_phone1" 和 "cell_service_phone2"编辑页面的区分
    
    public static final int BASE_OWNER_HOUSE_STATE_NEW_APPLY = 1;
    public static final int BASE_OWNER_HOUSE_STATE_NORMAL    = 2;
    
    public static final int SELFSTORE_Y = 1;//是自营店铺
    public static final int SELFSTORE_N = 0;//不是自营店铺
    
    /**
     * 新注册的用户
     */
    public static final int NEW_REGISTERER = 0;
    
    /**
     * 新注册的用户默认积分为0
     */
    public static final int ZERO_INTEGRAL = 0;
    
    /**
     * 新注册的用户默认登陆次数为0
     */
    public static final int ZERO_LOGINTIMES = 0;
    
	/**
	 * 空ID
	 */
	public static final String ID_ZERO = "0";
    
    /**
     * 状态
     */
    public static final int STATE_ENABLED = 1;
    public static final int STATE_DISABLED = 0;
    
    /**
     * 菜单状态
     */
    public static final int MENU_STATE_ENABLED = 1;
    public static final int MENU_STATE_DISABLED = 0;
    public static final short MENU_SELECT_NONE= -1;
    
    /**
     * 菜单级别
     */
    public static final short MENU_LEVEL_FIREST = 1;
    public static final short MENU_LEVEL_SECOND = 2;
    public static final short MENU_LEVEL_THREE = 3;
    public static final short MENU_LEVEL_FOUR = 4;
    
    /**
     * 区域分类级别
     */
    public static final int DISTRICT_LEVEL_FIRST = 1;
    public static final int DISTRICT_LEVEL_SECOND = 2;
    public static final int DISTRICT_LEVEL_THIRD = 3;
    
    /**
     * 默认密码
     */
    public static final String DEFALUT_PWD = "123456";
    
    /**
     * 功能状态
     */
    public static final int FUNCTION_ENABLED = 1; //启用
    public static final int FUNCTION_DISABLED = 0; //停用
    
    /**
     * SQL操作结果返回值常量
     * -1为数据异常，自定义错误描述
     */
    public static final int SQL_RESULT_SUCCESS = 1;
    public static final int SQL_RESULT_FAILD = 0;
    public static final int SQL_RESULT_ERROR = -1;
    public static final int SQL_RESULT_FAILD_CUSTOM = -2;
    
    /**
     * 文件类型：1-文件，2-目录
     */
    public static final int TYPE_FILE      = 1;
    public static final int TYPE_DIRECTORY = 2;
    
    /**
     * 新增或编辑页面类型：1-新增， 2-编辑
     */
    public static final int SAVE_TYPE  = 1; //新增类型
    public static final int EDIT_TYPE  = 2; //编辑类型
    
    
    public static final int MENU_TYPE = 1;//菜单类型
    public static final int BTN_TYPE = 2;//按钮类型
    
    /**
     * 分页大小
     */
    public static final int PAGE_SIZE  = 10; //默认每页大小
    public static final int PAGE_SIZE_TWENTY  = 20; //每页20条
    public static final int PAGE_SIZE_FIFTY  = 50; //每页50条
    public static final int PAGE_NO    = 1; //默认首页
    
    
    /**
     * 判断是否有依赖1：有依赖  0：没有依赖
     */
    public static final int IS_USED    = 1; //表示有依赖
    public static final int IS_NOT_USED    = 0; //表示没有依赖
    
    /**
     * 同步类型1:同步修改小区名称2：同步修改区域名称 3：同步修改楼栋名称 4：同步修改单元名称
     */
    public static final int CELL_TYPE        = 1; //表示小区名称同步
    public static final int REGION_TYPE      = 2; //表示区域名称同步
    public static final int BUILDING_TYPE    = 3; //表示楼栋名称同步
    public static final int UNIT_TYPE        = 4; //表示单元名称同步
    
    public static final int NO_ID  = 0; //传入的id为0
    
    /**
     * 选择框未选择
     */
    public static final int SELECT_NONE = -1;
    
    public static final int ADD_MEMO =1;  //类型：报修添加回复
    public static final int SEE_REVIEW =3;  //类型：查看报修回复的评价
    
    public static final int NORMAL_REPLY =1;  //类型：报修标准回复

    
    public static final int PAY_WAY_HOUTAI =0;  //后台缴费
    public static final int PAY_WAY_ALIPAY =1;  //支付宝
    public static final int PAY_WAY_YIPAY =2;  //翼支付
    public static final int PAY_WAY_INIT =3;  //初始化
    public static final int PAY_WAY_IMPORT =4;  //后台导入
    public static final int PAY_WAY_UNPAY =5;  //未支付
    public static final int PAY_WAY_WXPAY =6;  //微信
    public static final int PAY_WAY_BKPAY =7;  //贝壳支付

    public static final short COMPANY_TYPE_OPERATION = 0;//运营
    public static final short COMPANY_TYPE_PROPERTY = 1;//物业
    public static final short COMPANY_TYPE_DISTRIBUTION = 2;//配送
    
    /**
     * 物业收费
     */
    public static final BigDecimal INIT_RATE = BigDecimal.valueOf(1);//物业倍率
    public static final BigDecimal INIT_UNIT_PRICE = BigDecimal.valueOf(0.8);//单价
    public static final BigDecimal INIT_MONEY = BigDecimal.valueOf(0);//总价
    public static final int INIT_MONTH = 0;//总价
    public static final int ONE_MONTH = 1;//一个月
    public static final int NORMAL_STATE = 0;//正常
    public static final int AFTER_STATE = 1;//欠费
    public static final int BEFORE_STATE = 3;//预交费
    public static final int DEL_STATE = 4;//已删除
    public static final int GENERATE_WAY_INIT = 0;//初始化生成方式
    public static final int GENERATE_WAY_QUARTZ = 1;//定时任务生成
    public static final int GENERATE_WAY_IMPORT = 2;//  后台导入生成方式
    public static final int GENERATE_WAY_PRE = 3;//  预交费
    
    
    /**
     * 商品上下架
     */
    public static final int GOODS_SALE = 0;    //商品上架中
    public static final int GOODS_UNSALE = 1;  //商品下架
    
    /**
     * 购物车添加商品上限50
     */
    public static final int SHOPPING_CART_MAX_NUM = 50;
    
    /**
     * 商品店铺搜索
     */
    public static final int GOODS_SEARCH = 1;    //搜索商品
    public static final int SHOP_SEARCH = 2;  //搜索店铺
    
    /**
     * 帮助手册页面和报修问题页面区分
     */
    public static final int HELP_MANUAL = 1;    //帮助手册页面
    public static final int REPAIR_QUESTION = 2;  //报修问题页面
    
    /**
     * 账号页面区分
     */
    public static final int ADMIN_TYPE = 0;    //平台运营
    public static final int OPERATION_TYPE = 1;    //小区运营
    public static final int PROPERTY_TYPE = 2;  //物业类型
    public static final int BUSINESS_TYPE = 3;  //商户类型
    public static final int DISTRIBUTION_TYPE = 4;  //配送类型
    public static final int OWNER_TYPE = 5;  //业主类型
    
    public static final String ADMIN_TYPE_NAME = "平台运营";    //平台运营
    public static final String OPERATION_TYPE_NAME = "小区运营";    //小区运营
    public static final String PROPERTY_TYPE_NAME = "物业";  //物业类型
    public static final String BUSINESS_TYPE_NAME = "商户";  //商户类型
    public static final String DISTRIBUTION_TYPE_NAME = "配送";  //配送类型
    public static final String OWNER_TYPE_NAME = "业主";  //业主类型
    
    /**
     * 系统区分，涉及到菜单权限的系统
     */
    public static final int SYSTEM_OPERATION_WEB = 1;    //运营web
    public static final int SYSTEM_BUSINESS = 2;    //商户web及app
    public static final int SYSTEM_OWNER = 3;  //业主门户及app
    public static final int SYSTEM_DISTRIBUTION_APP = 4;  //配送app
    
    /**
     * 功能类型，仅对平台运维有用
     */
    public static final int MENU_TYPE_PLATFORM = 1;    //平台功能
    public static final int MENU_TYPE_CELL = 2;    //小区功能
    
    
    /**
     * 店铺状态
     */
    public static final int SHOP_STATE_NEW = 1;    //新申请
    public static final int SHOP_STATE_NORMAL = 2;  //正常
    public static final int SHOP_STATE_DISABLE = 3;  //禁用
    public static final int SHOP_STATE_SUSPEND = 4;  //暂停营业
    
    /**
     * 操作类型
     */
    public static final int FIND_PASSWORD = 1;    //找回密码
    public static final int BIND_PHONE = 2;  //绑定手机
    public static final int NEW_REGISTER = 3;  //注册
    
    /**
     * 订单状态
     */
    public static final int ORDER_ALL = -1;  //所有订单
    public static final int ORDER_UNPAID = 0; // 待付款
    public static final int ORDER_UNCONFORM = 1; // 待确认
    public static final int ORDER_UNSEND = 2; // 待发货
    public static final int ORDER_DISTRIBUTION_ING = 3; // 配送中
    public static final int ORDER_DONE = 4; // 已完成
    public static final int ORDER_CANCEL = 5; // 已取消
    public static final int ORDER_REFUND_APPLY = 6; // 退款申请
    public static final int ORDER_REFUND_CONFIRMED = 7; // 退款已确认
    public static final int ORDER_REFUND_DONE = 8; // 退款已完成
    public static final int ORDER_UNSERVICE = 9; // 待消费订单（原来是退款已拒绝）
    public static final int ORDER_RETURN_APPLY = 10; // 退货申请
    public static final int ORDER_RETURN_CONFIRMED = 11; // 退货已确认
    public static final int ORDER_RETURN_DONE = 12; // 退货已完成
    public static final int ORDER_RETURN_REFUSED = 13; // 退货已拒绝(无用)
    public static final int ORDER_DISTRIBUTION_DONE = 14; // 配送已送达
    
    public static final int ORDER_STATE_FIRST = 1; // 母订单
    public static final int ORDER_STATE_SECOND = 2; // 子订单
    

    public static final String SHOPS = "多家店铺"; // 多家店铺
    
    /**
     * 图片对象类型:1商品banner，2商品评价，3报修，4投诉，5小区头像
     */
    public static final int IMG_GOODS_BANNER   = 1;  //商品banner
    public static final int IMG_GOODS_APPRAISE = 2;  //商品评价
    public static final int IMG_REPAIRE        = 3;  //保修
    public static final int IMG_COMPLAIN       = 4;  //投诉
    public static final int IMG_CELLPIC        = 5;  //小区头像
    
    /**
     * 配送类型(在menu表里根据id区分)
     */
    public static final String DISTRIBUTION_ONE = "4001"; //抢单
    public static final String DISTRIBUTION_TWO = "4002"; //派单
    public static final String DISTRIBUTION_THERE = "4003"; //报表
    
    /**
     * 配送客户端类型
     */
    public static final int ANDROID = 1; //Android
    public static final int IOS = 2; //iOS
    
    /**
     * 超级管理员ID
     */
    public static final String SYS_ADMIN_ID = "15";
    
    public static final String DLIFE = "D生活";
    
    public static final String NO_STR = "无";
    
    public static final int INT_ZERO = 0;
    public static final int INT_ONE = 1;
    public static final int INT_TWO = 2;
    public static final int INT_THTEE = 3;
    
    public static final int COUPON_TYPE_FORUM = 1; // 平台
    public static final int COUPON_TYPE_SHOP = 2;  // 商铺
    
    public static final int GOODS_TYPE_NORMAL  = 1; // 正常商品
    public static final int GOODS_TYPE_CARDS   = 2; // 积分商品
    public static final int GOODS_TYPE_SECKILL = 3; // 秒杀商品
    
    public static final int IS_HAS_DISN_Y = 1; // 配送方式:配送公司配送
    public static final int IS_HAS_DISN_N = 2; // 配送方式:无配送
    
    public static final int IS_BYSELF_Y = 1; // 是否自提:是 
    public static final int IS_BYSELF_N = 0; // 是否自提:否
    
    public static final int PAY_TYPE_ALI = 1; // 支付宝
    public static final int PAY_TYPE_WX  = 2; // 微信
    public static final int PAY_TYPE_BK  = 3; // 贝壳支付

    public static final int DISTRIBUTION_COMPANY = 1;//配送
    public static final int DISTRIBUTION_SELF = 2;//自提
    
    public static final int PAY_SYSTEM_WEB = 1;//支付系统---web
    public static final int PAY_SYSTEM_APP = 2;

    public static final int PAY_SUCCESS = 0;//物业账单状态---缴费成功
    public static final int OWE_FEE = 1;//物业账单状态---欠费
    public static final int PRE_PAY = 3;//物业账单状态---预交费
    public static final int HAVE_DELETE = 4;//物业账单状态---已删除
    
    public static final int CAR_PAY_SUCCESS = 0;// 缴费成功
    public static final int CAR_NO_SYCN = 1;//已缴费未同步
    public static final int CAR_PRE_PAY = 3;//预交费
    public static final int CAR_HAVE_DELETE = 4;//已删除

    public static final int MONTH_TWELVE = 12;//月份-----12

    public static final int OPERATOR_TYPE_PROPERTY = 1;//操作人类型---1物业
    public static final int OPERATOR_TYPE_PROPREITOR = 2;//操作人类型---2业主
    
    public static final int ORDER_LEVEL_ONE = 1;
    public static final int ORDER_LEVEL_TWO = 2;
    
    // 订单类别
    public static final int ORDER_TYPE_MALL     = 1;  // 商城订单
    public static final int ORDER_TYPE_PROPERTY = 2;  // 物业费
    public static final int ORDER_TYPE_CAR      = 3;  // 停车费
    
    //配置类型
    public static final int PLATFOTM_CONFIG = 1;//平台配置
    public static final int CELL_CONFIG = 2;//小区配置
    public static final int PROPERTY_CONFIG = 3;//物业配置
    
    // 发票类型
    public static final int BILL_TYPE_NONE = 0; // 不需要
    public static final int BILL_TYPE_PERL = 1; // 个人
    public static final int BILL_TYPE_COMY = 2; // 单位
    
    // 优惠券状态
    public static final int COUPON_CREATE = 1; // 生成
    public static final int COUPON_UNUSE  = 2; // 下发
    public static final int COUPON_USED   = 3; // 使用

    /**
     * 商品评论等级
     */
    public static final int COMMENT_SCORE_ONE   = 1;
    public static final int COMMENT_SCORE_TWO   = 2;
    public static final int COMMENT_SCORE_THREE = 3;
    public static final int COMMENT_SCORE_FORE   = 4;
    public static final int COMMENT_SCORE_FIVE   = 5;
            
    
    /** 
     * @Title: getFunctionFromUserType 
     * @Description: 根据用户类型获取与相应的菜单类型
     * @param @param userType 用户类型
     * @param @return     
     * @return int     菜单类型
     * @throws 
     */
    public static int getFunctionFromUserType(int userType){
    	switch (userType) {
		case ADMIN_TYPE:
			return SYSTEM_OPERATION_WEB;
		case OPERATION_TYPE:
			return SYSTEM_OPERATION_WEB;
		case PROPERTY_TYPE:
			return SYSTEM_OPERATION_WEB;
		case BUSINESS_TYPE:
			return SYSTEM_BUSINESS;
		case DISTRIBUTION_TYPE:
			return SYSTEM_DISTRIBUTION_APP;
		default:
			return SYSTEM_OWNER;
		}
    }
    
    
    /** 
     * @Title: getPermissionByUser 
     * @Description: 获取用户可操作的用户类型
     * @param @param user 用户信息
     * @param @return     
     * @return List<SelectInfo>     可操作的用户类型
     * @throws 
     */
    public static List<SelectInfo> getPermissionByUser(User user){
    	List<SelectInfo> array = new ArrayList<SelectInfo>();
    	if(user == null || user.getUserType() == null){
    		return array;
    	}
    	
    	switch (user.getUserType()) {
		case ADMIN_TYPE://可操作所有
			array.add(new SelectInfo(ADMIN_TYPE, ADMIN_TYPE_NAME));
			array.add(new SelectInfo(OPERATION_TYPE, OPERATION_TYPE_NAME));
			array.add(new SelectInfo(PROPERTY_TYPE, PROPERTY_TYPE_NAME));
			array.add(new SelectInfo(BUSINESS_TYPE, BUSINESS_TYPE_NAME));
			array.add(new SelectInfo(DISTRIBUTION_TYPE, DISTRIBUTION_TYPE_NAME));
			break;
		case OPERATION_TYPE://可操作除开平台运营和小区运营的
			array.add(new SelectInfo(PROPERTY_TYPE, PROPERTY_TYPE_NAME));
			array.add(new SelectInfo(BUSINESS_TYPE, BUSINESS_TYPE_NAME));
			array.add(new SelectInfo(DISTRIBUTION_TYPE, DISTRIBUTION_TYPE_NAME));
			
			break;
		case PROPERTY_TYPE://只能操作物业自己
			array.add(new SelectInfo(PROPERTY_TYPE, PROPERTY_TYPE_NAME));
			break;
		default:
			break;
		}
    	
    	return array;
    }
    
    /** 默认编码 */
    public static final String DEFAULT_CHARSET = "UTF-8";
    
    /**
     * 推送消息信鸽密钥类型 1:业主app 2:商户app 3:配送app
     */
    public static final int XINGE_OWNERCONN = 1; //1:业主app
    public static final int XINGE_SHOPCONN = 2; //2:商户app
    public static final int XINGE_DISTRIBUTIONCONN = 3; //3:配送app
    
    /**
     * 各类消息推送类型
     */
    public static final int PUSH_TYPE_RUSH 		   = 1; //有新的订单待配送
    public static final int PUSH_TYPE_DISTRIBUTED  = 2; //有订单超时，需分配
    public static final int PUSH_TYPE_CONFIRMED	   = 3; //派送的订单业主已确认收货；
    public static final int PUSH_TYPE_DISTRIBUTION = 4; //管理员把订单派给了配送员
    
    public static final int OWNER_MESSAGE_CELL_INFO = 5; //小区通知
    public static final int OWNER_MESSAGE_GOODS_SEND = 6; //订单发货
    
    public static final int SHOP_MESSAGE_SYSTEM_INFO = 9; //系统推送消息
    
    public static final String APP_CACHE = "appCache";  //接口缓存
    
    /**
     * 各类首页需要展示的项目数目
     */
    public static final int SHOW_FIVE = 5; //展示5条
    public static final int SHOW_SIX = 6; //展示6条
    public static final int SHOW_SEVEN = 7; //展示7条
    
    /*********************************业主端**********************************/
    /**
     * 顶部菜单
     */
    public static final int INDEX_ITEM_HOME      = 1; // 首页
    public static final int INDEX_ITEM_ABOUT_US  = 2; // 关于我们
    public static final int INDEX_ITEM_JOIN_US   = 3; // 合作加盟
    public static final int INDEX_ITEM_ADVERTISE = 4; // 招贤纳士
    public static final int INDEX_ITEM_APP       = 5; // 客户端
    
    public static final int MAIN_ITEM_HOME = 1; // 首页
    public static final int MAIN_ITEM_INFO = 2; // 资讯
    public static final int MAIN_ITEM_PROY = 3; // 物业
    public static final int MAIN_ITEM_MALL = 4; // 商城
    public static final int MAIN_ITEM_SUGN = 5; // 投诉建议
    public static final int MAIN_ITEM_PERL = 6; // 个人中心
    
    
    /**
     * 微信支付
     */
    public static final String WEIXIN_INTERFACE = "https://api.mch.weixin.qq.com/pay/unifiedorder";
    public static final String WEIXIN_RESULT = "https://api.mch.weixin.qq.com/pay/orderquery";
    
    public static final String APPID  = "wxeec5cfb8ce5b9de9";  // 公众账号ID wxeec5cfb8ce5b9de9 wx426b3015555a46be
    public static final String MCH_ID = "1349754701";  // 商戶ID 1349754701 1225312702
    public static final String APPSECRET = "76202d375eef4a1661c0f416609de38d";
    public static final String KEY = "192006240b4c09247ec0edce69w6a2sd"; //e10adc3949ba59abbe56e057f20f883e
                                           
    /**
     * 个人中心首页，待付款，待收货，待评论，待发货，所有订单
     */
    public static final String WAIT_PAY_MONEY = "0";//待付款
    public static final String WAIT_RECEIVE_GOODS = "3,14";//待收货
    public static final String WAIT_COMMENT = "4,6,7,8,10,11,12,13";//待评价
    public static final String WAIT_SEND_GOODS = "2";//待发货
    public static final String ALL_ORDER = "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14";//所有订单
    
    /**
     * 商户
     */
    public static final String SELLER_WAIT_COMFIRM = "1,6,10";//商户待确认
    public static final String SELLER_REFUND = "6,7,8";//商户退款订单
    public static final String SELLER_WAIT_PAY = "0";//商户待付款订单
    public static final String SELLER_WAIT_SEND = "2";//商户待发货订单
    public static final String SELLER_WAIT_TREAT = "1,2,6,10";//商户待处理订单
    
    
    /**
     * 批量导入数据时，sort默认设成0
     */
    public static final Integer SORT_DEFAULT = 0;
     
    /**
     * 推送消息推送端区分
     */
    public static final Integer PUSH_STATE_PROPRIETOR = 1;//1:业主app
    public static final Integer PUSH_STATE_SELLER = 2;//2:商户app
    public static final Integer PUSH_STATE_DISTRIBUTION = 3;//3:配送app
    
    /**
     * 根据时间查看报表
     */
    public static final int SEARCH_FIXED = 1;//固定搜索
    public static final int SEARCH_FREE  = 2;//自由搜索

    public static final int ORDER_CANCEL_TYPE_SELLER  = 1;//商户
    public static final int ORDER_CANCEL_TYPE_OWNER = 2;//业主
    
    /**
     *  图片存放obj_type
     */
    public static final int OWNER_COMPLAINTS = 4;//投诉
    public static final int OWNER_REPAIRINFO = 3;//报修
    
    /**
     *  个首页item
     */
    public static final int ITEM_MAIN = 1; //首页
    public static final int ITEM_INFORMATION = 2; //资讯
    public static final int ITEM_PROPERTY = 3; //物业
    public static final int ITEM_MALL = 4; //商城
    public static final int ITEM_SUGGESTION = 5; //投诉建议
    public static final int ITEM_PERSONAL = 6; //个人中心
    
    /**
     *  用户类型
     */
    public static final int USER_OPERATION = 1; //运营
    public static final int USER_PROPERTY = 2; //物业
    public static final int USER_DISTRIBUTION =4; //配送
    public static final int USER_OWNER = 5; //业主
    
    /**
     *  优惠劵状态
     */
    public static final int COUPON_NORMAL = 2; //正常
    
    
    public static final String PROPERTY_PAY_TIME = "property_feebill_paytime";
    
    public static String getPayState(int state){
        String result = "";
        switch (state) {
            case Constants.CAR_PAY_SUCCESS:
                result = "缴费成功";
                break;
            case Constants.CAR_NO_SYCN:
                result = "已缴费未同步";
                break;
            case Constants.CAR_PRE_PAY:
                result = "预缴费";
                break;
            case Constants.CAR_HAVE_DELETE:
                result = "已删除";
                break;
            default:
                break;
        }
        return result;
    }
    public static String getPayWay(int type) {
        String result = "";
        switch (type) {
            case PAY_WAY_HOUTAI:
                result = "后台缴费";
                break;
            case PAY_WAY_ALIPAY:
                result = "支付宝";
                break;
            case PAY_WAY_YIPAY:
                result = "翼支付";
                break;
            case PAY_WAY_INIT:
                result = "初始化";
                break;
            case PAY_WAY_IMPORT:
                result = "后台导入";
                break;
            case PAY_WAY_UNPAY:
                result = "未支付";
                break;
            case PAY_WAY_WXPAY:
                result = "微信";
                break;
            case PAY_WAY_BKPAY:
                result = "贝壳支付";
                break;
            default:
                break;
        }
        return result;
    }
    
}
